#pragma once
class CMeasureSerial :
  public CSerialMFC
{
  friend class boost::serialization::access;

public:
  CMeasureSerial(void);
  CMeasureSerial(const CMeasureSerial& serial);
  CMeasureSerial(const tstring& Name, const tstring& Device, CWnd* wnd);
  ~CMeasureSerial(void);

  void Init(void);

public:
  long OpenSerial(void)
  { 
    return CSerialMFC::Open(device_.c_str(), dst_wnd_,
      CSerialWnd::mg_nDefaultComMsg, (LPARAM)this, 0, 0); 
  }

  void SetupParam(void);

  bool IsBusy(void) const;

public:
  const tstring& Name(void) const { return name_; }
  void set_name(const tstring& val) { name_ = val; }

  const tstring& cmd_name(void) const { return cmd_name_; }
  void set_cmd_name(const tstring& val) { cmd_name_ = val; }

  const tstring& device(void) const { return device_; }
  void set_device(const tstring& val) { device_ = val; }

  CWnd* dst_wnd(void) const { return dst_wnd_; }
  void set_dst_wnd(CWnd* val) { dst_wnd_ = val; }

  tstring status_string(void) const;

private:
  CWnd* dst_wnd_;

private:
  tstring    name_;
  tstring    cmd_name_;
  tstring    device_;
  EBaudrate  baud_rate_;
  EDataBits  data_bits_;
  EParity    parity_;
  EStopBits  stop_bits_;
  EHandshake hand_shake_;
  DWORD      event_mask_;
  char       event_char_;

  template<class Archive>
  void serialize(Archive &ar, const unsigned int)
  {
    using boost::serialization::make_nvp;
    ar & make_nvp("name",         name_);
    ar & make_nvp("cmd_name",     cmd_name_);
    ar & make_nvp("device",       device_);
    ar & make_nvp("baud_rate",    baud_rate_);
    ar & make_nvp("data_bits",    data_bits_);
    ar & make_nvp("parity",       parity_);
    ar & make_nvp("stop_bits",    stop_bits_);
    ar & make_nvp("hand_shake",   hand_shake_);
    ar & make_nvp("event_mask",   event_mask_);
    ar & make_nvp("event_char",   event_char_);
  }
};

BOOST_CLASS_VERSION(CMeasureSerial, 0)

